package utils

import (
	"log"
	"os"
	"path"
	"runtime"
	"strings"
)

var RootPath string

func setPath() string {
	_, filename, _, ok := runtime.Caller(1)
	if ok {
		RootPath = path.Join(path.Dir(path.Dir(filename)), "") // the the main function file directory
	} else {
		RootPath = "./"
	}
	return RootPath
}

func getPwd() string {
	dir, err := os.Getwd()
	if err != nil {
		log.Fatal(err)
	}
	var pwd string
	pwd = strings.Replace(dir, "\\", "/", -1)
	return pwd
}

func init() {
	setPath()
}
